import { createRouter, createWebHistory } from 'vue-router'
import ContactView from '@/components/ContactView.vue'
import AboutView from '@/components/AboutView.vue'
import HomeView from '@/components/HomeView.vue'
import UserView from '@/components/UserView.vue'
import GoodsDetail from '@/components/GoodsDetail.vue'
import SignView from '@/components/SignView.vue'

 const routes = [
 {
 path: '/',
 name: 'Home',
 component: HomeView
 },
 {
 path: '/about',
 name: 'About',
 component: AboutView
 },
 {
 path: '/contact',
 name: 'Contact',
 component: ContactView
 },
 {
 path: '/user',
 name: 'user',
 // eslint-disable-next-line no-undef
 component: UserView
 },
 {
 path: '/sign',
 name: 'sign',
 // eslint-disable-next-line no-undef
 component: SignView
 },
 {
 path: '/goods/detail/:id',
 name: 'detail',
 // eslint-disable-next-line no-undef
 component: GoodsDetail
 }
 ]


 const router = createRouter({
 history: createWebHistory(),
 routes
 })

router.beforeEach((to,from,next)=>{
    if(to.name=="About"){
        console.log("进入about页面")
    }
    next()
})

 export default router